/**
 * Created with Intellij JDEA
 * Description:
 * User:
 * Date:2022-05-07
 * Time:14:05
 */
public class 乘积小于K的子数组 {
    public int numSubarrayProductLessThanK(int[] nums, int k) {
        int count = 0;
        for(int i = 0;i < nums.length;i++) {
            int sum = 1;
            for(int j = i;j < nums.length;j++) {
                if(i == j) {
                    if(nums[i] < k){
                        count++;
                        sum *= nums[j];
                    }else{
                        break;
                    }
                }else {
                    sum *= nums[j];
                    if(sum < k) {
                        count++;
                    }
                }
                if(sum > k) {
                    break;
                }
            }
        }
        return count;
    }
}
